import type { RouteRecordRaw } from 'vue-router'
import Books from '@/views/Books.vue'
/**
 * 路由配置
 * @description 所有路由都在这里集中管理
 */
const routes: RouteRecordRaw[] = [
  /**
   * 首页
   */
  {
    path: '/',
    redirect: {
      name: 'home',
    },
  },
  {
    path: '/home',
    name: 'home',
    meta: {
      title: '首页',
    },
    component: () => import('@/views/Home.vue'),
  },
  {
    path: '/category/:id',
    name: 'category',
    meta: {
      title: '图书分类',
    },
    component: Books,
  },
  {
    path: '/search',
    name: 'search',
    meta: {
      title: '搜索结果',
    },
    component: Books,
  },
  {
    path: '/newBooks',
    name: 'newBooks',
    meta: {
      title: '新书上市',
    },
    component: () => import('../../components/BooksNew.vue'),
  },
  {
    path: '/book/:id',
    name: 'book',
    meta: {
      title: '图书',
    },
    component: () => import('../../views/Book.vue'),
  },
  {
    path: '/cart',
    name: 'cart',
    meta: {
      title: '购物车',
    },
    component: () => import('../../views/ShoppingCart.vue'),
  },
  {
    path: '/register',
    name: 'register',
    meta: {
      title: '注册',
    },
    component: () => import('../../components/UserRegister.vue'),
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录',
    },
    component: () => import('../../components/UserLogin.vue'),
  },
  {
    path: '/check',
    name: 'check',
    meta: {
      title: '结算',
      requiresAuth: true,
    },
    component: () => import('../../views/Checkout.vue'),
  },
]

export default routes
